import { maintenanceHttp } from '/@/utils/http/axios';
import {
  AppItem,
  BasicDataItem,
  BasicItem,
  ComponentItem,
  DetailAppItem,
  DetailParams,
  PackageItem,
  PageParams,
  RdsItem,
  SubScribedAppPageParams,
  SubScribedResultModel,
  SummeryItem,
  TenantItem,
} from '/@/api/maintenance-center/resource-statistics/model/resourceStatisticsModel';

enum Api {
  GET_SUBSCRIBED_APP_LIST = '/v1/maintenance/resourceStatistics/queryList',
  GET_SUBSCRIBED_APP_DETAIL = '/v1/maintenance/resourceStatistics/queryAppResourceDetails',
  GET_BASIC_DATA = '/v1/maintenance/resourceStatistics/baseData',
  GET_TENANT_CODE = '/v1/maintenance/resourceStatistics/queryTenantList',
  GET_APP_ID = '/v1/maintenance/resourceStatistics/queryAppList',
  GET_RDS_DETAIL = '/v1/maintenance/resourceStatistics/queryRdsDetails',
  GET_PACKAGE_DETAIL = '/v1/maintenance/resourceStatistics/queryPackageDetails',
  GET_ORDINARY_DETAIL = '/v1/maintenance/resourceStatistics/queryOrdinaryDetails',
  GET_COMPONENT_DETAIL = '/v1/maintenance/resourceStatistics/queryCceAndCseDetails',
  GET_SUMMERY_RESOURCE = '/v1/maintenance/resourceStatistics/tenant/queryTenantSummaryResource',
}
export const getSubscribedAppList = async (params: SubScribedAppPageParams) => {
  // 获取订阅应用列表
  const data = maintenanceHttp.get<SubScribedResultModel>({
    url: Api.GET_SUBSCRIBED_APP_LIST,
    params,
  });
  return data;
};
export const viewAppDetail = (params: DetailParams) => {
  // 获取订阅应用详情
  return maintenanceHttp.get<DetailAppItem>({
    url: Api.GET_SUBSCRIBED_APP_DETAIL,
    params,
  });
};

export const getBasicData = async () => {
  // 获取资源监控基础数据
  const res = await maintenanceHttp.get<BasicDataItem>({
    url: Api.GET_BASIC_DATA,
  });
  return res;
};

export const getTenantCode = () => {
  return maintenanceHttp.get<TenantItem>({ url: Api.GET_TENANT_CODE });
};

export const getAppId = () => {
  return maintenanceHttp.get<AppItem>({ url: Api.GET_APP_ID });
};

export const getRdsDetail = (params: PageParams) => {
  return maintenanceHttp.get<RdsItem>({ url: Api.GET_RDS_DETAIL, params });
};
export const getPackageDetail = (params: PageParams) => {
  return maintenanceHttp.get<PackageItem>({
    url: Api.GET_PACKAGE_DETAIL,
    params,
  });
};
export const queryOrdinaryDetails = (params: PageParams) => {
  return maintenanceHttp.get<BasicItem>({
    url: Api.GET_ORDINARY_DETAIL,
    params,
  });
};
export const getComponentDetail = (params: PageParams) => {
  return maintenanceHttp.get<ComponentItem[]>({
    url: Api.GET_COMPONENT_DETAIL,
    params,
  });
};

export const getTenantSummery = () => {
  return maintenanceHttp.get<SummeryItem>({ url: Api.GET_SUMMERY_RESOURCE });
};
